﻿using Core;

namespace g_gongjianta
{
    public class LinkNode : Component
    {
        public TblSkill.Link Link { get; private set; }

        public bool IsTrigger { get; private set; } = false;

        private SenseComponent sense;

        public void Init(TblSkill.Link link, SenseComponent comp)
        {
            IsTrigger = false;
            Link = link;

            sense = comp;
        }

        public void Check(int frame)
        {
            if (frame < Link.StartFrame || frame > Link.EndFrame)
            {
                return;
            }

            if (sense.Contains(Link.Type))
            {
                IsTrigger = true;
            }
        }

        public void Reset()
        {
            //IsOnCache = false;
            IsTrigger = false;
        }

        public void Clear()
        {
            Reset();
        }
    }
}
